package net.heri.xmppchat.activities;

import net.heri.xmppchat.R;
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.util.Log;

import com.google.inject.Inject;

@SuppressLint("NewApi")
public class ChatSettingsFragment extends PreferenceFragment {

	private final String TAG = ChatSettingsFragment.class.getSimpleName();
	
	// Preference Keys
	private static final String KEY_SERVICE_ENABLED = "chat_service_enable";
	
	@Inject
	private SharedPreferences pref;
	
	private SharedPreferences.OnSharedPreferenceChangeListener listener = new SharedPreferences.OnSharedPreferenceChangeListener() {		
		@Override
		public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {			
			boolean val = sharedPreferences.getBoolean(key, false);
			Log.i(TAG, String.format("Value key[%s] is [%s]", key, val));
		}
	};
	
	public ChatSettingsFragment() {
		super();
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		Log.i(TAG, "onCreate");
		
		super.onCreate(savedInstanceState);		
		pref.registerOnSharedPreferenceChangeListener(listener);
		addPreferencesFromResource(R.xml.settings);
	}
}
